package org.rockNarwhal.service.impl;

import org.rockNarwhal.domain.Role;
import org.rockNarwhal.mapper.RoleMapper;
import org.rockNarwhal.service.RoleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashSet;
import java.util.List;
import java.util.Set;
@Service
public class RoleServiceImpl implements RoleService {
    @Autowired
    RoleMapper roleMapper;
    @Override
    public Set<String> listRoles(String username) {
        Set<String> roles=null;
        List<Role> roleList = roleMapper.listRoleByUsername(username);
        if(roleList!=null&&roleList.size()>0){
            roles=new HashSet<>();
            for(Role r:roleList){
                roles.add(r.getName());
            }
        }
        return roles;
    }
}
